<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    function Stack(){
        this.data=[];
        this.top=0;
    }
    Stack.prototype={
        constructor:Stack,
        push: function (elm) {
            this.data[this.top++]=elm;
        },
        pop: function () {
            return this.data[--this.top];
        },
        peek: function () {
            return this.data[this.top-1];
        },
        size: function () {
            return this.top;
        },
        clear: function () {
            delete this.data;
            this.data=[];
            this.top=0;
        }
    }

    function fb(n){
        var s=new Stack(),r=1;
        while(n>1){
            s.push(n--);
        }
        console.log(s.data);
        do{
            r*= s.pop();
        }while(s.size());
        return r;
    }

    console.log(fb(5));
</script>
</body>
</html>